package com.klondike.common.concurrent;

class RefObjcet {
    private String ref;

    public RefObjcet(String ref) {
        this.ref = ref;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        RefObjcet other = (RefObjcet) obj;
        if (ref == null) {
            if (other.ref != null)
                return false;
        } else if (!ref.equals(other.ref))
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((ref == null) ? 0 : ref.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return ref;
    }

    public static RefObjcet of(String ref) {
        return new RefObjcet(ref);
    }

    public static RefObjcet of(RefObjcet ref) {
        return new RefObjcet(ref.ref);
    }
}